//
//  TaskTableViewCell.m
//  Molian
//
//  Created by 胡津 on 15/4/1.
//  Copyright (c) 2015年 xiaocan. All rights reserved.
//

#import "TaskTableViewCell.h"

@implementation TaskTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        //cell背景
        UIView *cellview = [[UIView alloc]initWithFrame:CGRectMake(10, 5, DeviceWidth-20, 100)];
        cellview.clipsToBounds = NO;
        cellview.layer.masksToBounds = YES;//开启圆角
        [cellview.layer setCornerRadius:7];
        cellview.backgroundColor = [UIColor whiteColor];
        [cellview.layer setBorderColor:[RGBA(191, 191, 191, 1) colorWithAlphaComponent:1].CGColor];
        [cellview.layer setBorderWidth:0.3];
        [self.contentView addSubview:cellview];
        
        
        self.taskTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, DeviceWidth-130, 20)];
        self.taskDetailsLabel.font = [UIFont fontWithName:FontName size:16];
        [cellview addSubview:self.taskTitleLabel];
        
        self.taskDetailsLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 40, DeviceWidth-130, 50)];

        self.taskDetailsLabel.font = [UIFont fontWithName:FontName size:14];
        [self.taskDetailsLabel setTextColor:[UIColor grayColor]];
        self.taskDetailsLabel.numberOfLines = 2;
        [cellview addSubview:self.taskDetailsLabel];
        
        
        self.taskResultBtn = [[UIButton alloc]initWithFrame:CGRectMake(DeviceWidth-120, (100-30)/2, 80, 30)];
        self.taskResultBtn.layer.masksToBounds = YES;//开启圆角
        self.taskResultBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
        [self.taskResultBtn.layer setCornerRadius:15];
        [cellview addSubview:self.taskResultBtn];
        
        
    }
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.selectedBackgroundView.layer.masksToBounds = YES;//开启圆角
    [self.selectedBackgroundView.layer setCornerRadius:7];
    self.selectedBackgroundView.frame = CGRectMake(10, 5, DeviceWidth-20, 100);
    
    
    if ([self.taskResultBtn.titleLabel.text isEqualToString:@"去完成"]) {
        [self.taskResultBtn setBackgroundColor:RGBA(248, 207, 30, 1)];
    }else if ([self.taskResultBtn.titleLabel.text isEqualToString:@"领奖励"]){
        [self.taskResultBtn setBackgroundColor:[UIColor paperColorGreenA200]];
    }else{
        [self.taskResultBtn setBackgroundColor:RGBA(234, 234, 234, 1)];
    }
    
}
@end
